package com.example.wnn.web.vo;
import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.example.wnn.utils.VersionCompareUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.Objects;

public class CurlExecutor {

    public static void main(String[] args) {
//        try {
//
//            String curlCommand = "curl --request POST \\\n" +
//                    "  --url https://ai.xinhua-news.cn/auth/session \\\n" +
//                    "  --header 'Content-Type: application/x-www-form-urlencoded' \\\n" +
//                    "  --header 'Origin: https://ai.xinhua-news.cn' \\\n" +
//                    "  --header 'content-type: application/x-www-form-urlencoded' \\\n" +
//                    "  --data username=bjtkxmt \\\n" +
//                    "  --data 'password=asd!us943k2kkcD'"; // 根据需要调整curl参数
//
//            Process process = Runtime.getRuntime().exec(curlCommand);
//            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
//
//             String var = "{\n" +
//                     "    \"result\": {\n" +
//                     "        \"id_token\": \"eyJhbGciOiJSUzI1NiIsImtpZCI6IlhDd3hhTTBqb0NZNnhDaUYtUGpxZGZwdGx1aUh1RVIzTmN6WHF6UVZ1RVkiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOlsiYWkueGluaHVhLW5ld3MuY24iXSwiYXV0aF90aW1lIjoxNTkzNjY2NTg2LCJleHAiOjE1OTM2NzAxODYsImlhdCI6MTU5MzY2NjU4NiwiaXNzIjoiaHR0cDovL2FpLnhpbmh1YS1uZXdzLmNuOjMwMDAiLCJzdWIiOiIyOSJ9.DLm6qbtoJC6gHvR4mUbwstwmvKGh7iT773x3bj9hmzGsWD3fIsZ5pszzf4cLENJkvsWg6eiTZq_0k0xcb9NXvGVoxYMWI1eaVwMYPPpDs8vVJd3a5w_6_sCmRsLr6yuJDluAg2mLoz_tAYvGIsUFFBreFmAojKRe2Lk5CSHKq7gtDdB9MIXGiy2LWVEZJU9IGRWMp7o6hu4UH3gCDWzBvJF2J9SHs8ie3BdxBhbmSJPkl1vHMoqXJSLFtJH69Fv6Nj7TbdhdJi0gLR9v9m0nyp_185oGMQkMfB19ODdZMFeCWF6rm6Gq9vmrtOe3siP3fYOxPltIz3WXoCNmJ84g\"\n" +
//                     "    }\n" +
//                     "}";
//             Map<String,Object> map =  JSONUtil.toBean(var, Map.class);
//             if (map.containsKey("result")){
//                 Map<String,String> tokenMap =  JSONUtil.toBean(MapUtil.getStr(map,"result"), Map.class);
//                 if (Objects.nonNull(tokenMap) && tokenMap.containsKey("id_token")){
//                     System.out.println(tokenMap.get("id_token"));
//                 }
//             }
//
//
//            int exitVal = process.waitFor();
//            System.out.println("Exited with code: " + exitVal);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        String appVersion = "5.4.7";
        boolean afterV540 = VersionCompareUtil.versionCompare(appVersion,"5.4.0");
        if (!afterV540){
            System.out.println(1);
        }else {
            System.out.println(2);
        }

        JSONObject recommendSource = new JSONObject();
        recommendSource.put("a","aaa");
        System.out.println(recommendSource.getStr("context"));
    }


}